Skip to content

fix: update observedGeneration on Gateway-API route status conditions (apache/apisix-ingress-controller#2768)#418

Merged
AlinsRan merged 2 commits into
masterfrom
fix/update-observed-generation-gateway-api-route-status-v2
May 26, 2026
Merged

fix: update observedGeneration on Gateway-API route status conditions (apache/apisix-ingress-controller#2768)#418
AlinsRan merged 2 commits into
masterfrom
fix/update-observed-generation-gateway-api-route-status-v2

Conversation

@AlinsRan
Copy link
Copy Markdown
Contributor

@AlinsRan AlinsRan commented May 26, 2026

Stamps condition.ObservedGeneration = cp.GetGeneration() inside the four Gateway-API mutator closures (HTTPRoute, UDPRoute, TCPRoute, GRPCRoute) before MergeCondition, mirroring what SetApisixCRDConditionWithGeneration already does for the legacy CRDs.

Before (HTTPRoute after a sync failure→recovery cycle):

metadata:
  generation: 1
status:
  parents:
  - conditions:
    - type: Accepted
      status: "True"
      observedGeneration: 0   # mismatched

After:

metadata:
  generation: 1
status:
  parents:
  - conditions:
    - type: Accepted
      status: "True"
      observedGeneration: 1   # matches metadata.generation

Summary by CodeRabbit

  • Bug Fixes

    • Corrected route status reporting so the observedGeneration is now populated for Gateway API route statuses (HTTP, UDP, TCP, GRPC), improving accuracy of change tracking.
  • Tests

    • Updated end-to-end checks to assert observedGeneration in route status after scaling events.

Review Change Stack

Stamps condition.ObservedGeneration = cp.GetGeneration() inside the four
Gateway-API mutator closures (HTTPRoute, UDPRoute, TCPRoute, GRPCRoute)
before MergeCondition, mirroring what SetApisixCRDConditionWithGeneration
already does for the legacy CRDs.

Backport of apache/apisix-ingress-controller#2768

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

The PR sets condition.ObservedGeneration to each route object's current generation inside the status mutators for HTTPRoute, UDPRoute, TCPRoute, and GRPCRoute, and updates an e2e test to assert observedGeneration: 1 in HTTPRoute status.

Changes

ObservedGeneration field population

Layer / File(s) Summary
ObservedGeneration in route status mutators
internal/provider/apisix/status.go, internal/provider/api7ee/status.go
HTTPRoute, UDPRoute, TCPRoute, and GRPCRoute status updater mutators set condition.ObservedGeneration from the route's GetGeneration() before merging/updating parent reference conditions.
ObservedGeneration assertion in e2e status test
test/e2e/gatewayapi/status.go
E2E Gateway API status test now asserts observedGeneration: 1 in HTTPRoute status after scaling.

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
E2e Test Quality Review ⚠️ Warning E2E test covers only HTTPRoute; implementation modifies 4 route types (HTTP/UDP/TCP/GRPC) identically without tests for UDP/TCP/GRPC status conditions. Add observedGeneration assertions to UDPRoute, TCPRoute, and GRPCRoute E2E status tests to match implementation scope covering all 4 affected Gateway-API route types.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating observedGeneration on Gateway-API route status conditions. It directly matches the code changes across multiple files and the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed PR adds metadata-only changes setting Condition.ObservedGeneration in Gateway API route mutators; no credentials, secrets, DB, auth, or resource isolation issues found.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/update-observed-generation-gateway-api-route-status-v2

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

conformance test report - apisix-standalone mode

apiVersion: gateway.networking.k8s.io/v1
date: "2026-05-26T03:48:27Z"
gatewayAPIChannel: experimental
gatewayAPIVersion: v1.3.0
implementation:
  contact: null
  organization: APISIX
  project: apisix-ingress-controller
  url: https://github.com/apache/apisix-ingress-controller.git
  version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
    result: success
    statistics:
      Failed: 0
      Passed: 12
      Skipped: 0
  name: GATEWAY-GRPC
  summary: Core tests succeeded.
- core:
    result: partial
    skippedTests:
    - HTTPRouteHTTPSListener
    statistics:
      Failed: 0
      Passed: 32
      Skipped: 1
  extended:
    result: partial
    skippedTests:
    - HTTPRouteRedirectPortAndScheme
    statistics:
      Failed: 0
      Passed: 11
      Skipped: 1
    supportedFeatures:
    - GatewayAddressEmpty
    - GatewayPort8080
    - HTTPRouteBackendProtocolWebSocket
    - HTTPRouteDestinationPortMatching
    - HTTPRouteHostRewrite
    - HTTPRouteMethodMatching
    - HTTPRoutePathRewrite
    - HTTPRoutePortRedirect
    - HTTPRouteQueryParamMatching
    - HTTPRouteRequestMirror
    - HTTPRouteResponseHeaderModification
    - HTTPRouteSchemeRedirect
    unsupportedFeatures:
    - GatewayHTTPListenerIsolation
    - GatewayInfrastructurePropagation
    - GatewayStaticAddresses
    - HTTPRouteBackendProtocolH2C
    - HTTPRouteBackendRequestHeaderModification
    - HTTPRouteBackendTimeout
    - HTTPRouteParentRefPort
    - HTTPRoutePathRedirect
    - HTTPRouteRequestMultipleMirrors
    - HTTPRouteRequestPercentageMirror
    - HTTPRouteRequestTimeout
  name: GATEWAY-HTTP
  summary: Core tests partially succeeded with 1 test skips. Extended tests partially
    succeeded with 1 test skips.
- core:
    result: partial
    skippedTests:
    - TLSRouteSimpleSameNamespace
    statistics:
      Failed: 0
      Passed: 10
      Skipped: 1
  name: GATEWAY-TLS
  summary: Core tests partially succeeded with 1 test skips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

conformance test report - apisix mode

apiVersion: gateway.networking.k8s.io/v1
date: "2026-05-26T03:48:45Z"
gatewayAPIChannel: experimental
gatewayAPIVersion: v1.3.0
implementation:
  contact: null
  organization: APISIX
  project: apisix-ingress-controller
  url: https://github.com/apache/apisix-ingress-controller.git
  version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
    result: success
    statistics:
      Failed: 0
      Passed: 12
      Skipped: 0
  name: GATEWAY-GRPC
  summary: Core tests succeeded.
- core:
    failedTests:
    - HTTPRouteInvalidBackendRefUnknownKind
    result: failure
    skippedTests:
    - HTTPRouteHTTPSListener
    statistics:
      Failed: 1
      Passed: 31
      Skipped: 1
  extended:
    result: partial
    skippedTests:
    - HTTPRouteRedirectPortAndScheme
    statistics:
      Failed: 0
      Passed: 11
      Skipped: 1
    supportedFeatures:
    - GatewayAddressEmpty
    - GatewayPort8080
    - HTTPRouteBackendProtocolWebSocket
    - HTTPRouteDestinationPortMatching
    - HTTPRouteHostRewrite
    - HTTPRouteMethodMatching
    - HTTPRoutePathRewrite
    - HTTPRoutePortRedirect
    - HTTPRouteQueryParamMatching
    - HTTPRouteRequestMirror
    - HTTPRouteResponseHeaderModification
    - HTTPRouteSchemeRedirect
    unsupportedFeatures:
    - GatewayHTTPListenerIsolation
    - GatewayInfrastructurePropagation
    - GatewayStaticAddresses
    - HTTPRouteBackendProtocolH2C
    - HTTPRouteBackendRequestHeaderModification
    - HTTPRouteBackendTimeout
    - HTTPRouteParentRefPort
    - HTTPRoutePathRedirect
    - HTTPRouteRequestMultipleMirrors
    - HTTPRouteRequestPercentageMirror
    - HTTPRouteRequestTimeout
  name: GATEWAY-HTTP
  summary: Core tests failed with 1 test failures. Extended tests partially succeeded
    with 1 test skips.
- core:
    result: partial
    skippedTests:
    - TLSRouteSimpleSameNamespace
    statistics:
      Failed: 0
      Passed: 10
      Skipped: 1
  name: GATEWAY-TLS
  summary: Core tests partially succeeded with 1 test skips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

conformance test report

apiVersion: gateway.networking.k8s.io/v1
date: "2026-05-26T04:06:22Z"
gatewayAPIChannel: experimental
gatewayAPIVersion: v1.3.0
implementation:
  contact: null
  organization: APISIX
  project: apisix-ingress-controller
  url: https://github.com/apache/apisix-ingress-controller.git
  version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
    failedTests:
    - GatewayModifyListeners
    result: failure
    statistics:
      Failed: 1
      Passed: 11
      Skipped: 0
  name: GATEWAY-GRPC
  summary: Core tests failed with 1 test failures.
- core:
    failedTests:
    - GatewayModifyListeners
    result: failure
    skippedTests:
    - HTTPRouteHTTPSListener
    statistics:
      Failed: 1
      Passed: 31
      Skipped: 1
  extended:
    failedTests:
    - HTTPRouteBackendProtocolWebSocket
    result: failure
    skippedTests:
    - HTTPRouteRedirectPortAndScheme
    statistics:
      Failed: 1
      Passed: 10
      Skipped: 1
    supportedFeatures:
    - GatewayAddressEmpty
    - GatewayPort8080
    - HTTPRouteBackendProtocolWebSocket
    - HTTPRouteDestinationPortMatching
    - HTTPRouteHostRewrite
    - HTTPRouteMethodMatching
    - HTTPRoutePathRewrite
    - HTTPRoutePortRedirect
    - HTTPRouteQueryParamMatching
    - HTTPRouteRequestMirror
    - HTTPRouteResponseHeaderModification
    - HTTPRouteSchemeRedirect
    unsupportedFeatures:
    - GatewayHTTPListenerIsolation
    - GatewayInfrastructurePropagation
    - GatewayStaticAddresses
    - HTTPRouteBackendProtocolH2C
    - HTTPRouteBackendRequestHeaderModification
    - HTTPRouteBackendTimeout
    - HTTPRouteParentRefPort
    - HTTPRoutePathRedirect
    - HTTPRouteRequestMultipleMirrors
    - HTTPRouteRequestPercentageMirror
    - HTTPRouteRequestTimeout
  name: GATEWAY-HTTP
  summary: Core tests failed with 1 test failures. Extended tests failed with 1 test
    failures.
- core:
    failedTests:
    - GatewayModifyListeners
    - TLSRouteSimpleSameNamespace
    result: failure
    statistics:
      Failed: 2
      Passed: 9
      Skipped: 0
  name: GATEWAY-TLS
  summary: Core tests failed with 2 test failures.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/provider/api7ee/status.go (1)

267-268: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Missing ObservedGeneration assignment for TLSRoute.

The TLSRoute mutator does not set condition.ObservedGeneration, unlike HTTPRoute (line 125), UDPRoute (line 161), TCPRoute (line 197), and GRPCRoute (line 233). Context snippet 1 shows that VerifyConditions refuses to apply a newer condition when the existing condition has a higher ObservedGeneration, so without this assignment TLSRoute status updates will be blocked after the first sync cycle when the existing condition's ObservedGeneration becomes non-zero.

🔧 Proposed fix
 		Mutator: status.MutatorFunc(func(obj client.Object) client.Object {
 			cp := obj.(*gatewayv1alpha2.TLSRoute).DeepCopy()
+			condition.ObservedGeneration = cp.GetGeneration()
 			gatewayNs := cp.GetNamespace()
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/provider/api7ee/status.go` around lines 267 - 268, The TLSRoute
status mutator is missing assignment of condition.ObservedGeneration, causing
VerifyConditions to reject newer updates; inside the MutatorFunc for TLSRoute
(where cp := obj.(*gatewayv1alpha2.TLSRoute).DeepCopy() is created) set the
condition.ObservedGeneration to cp.Generation (same pattern used in
HTTPRoute/UDPRoute/TCPRoute/GRPCRoute mutators) before applying or replacing the
condition so status updates are allowed to proceed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/provider/api7ee/status.go`:
- Around line 267-268: The TLSRoute status mutator is missing assignment of
condition.ObservedGeneration, causing VerifyConditions to reject newer updates;
inside the MutatorFunc for TLSRoute (where cp :=
obj.(*gatewayv1alpha2.TLSRoute).DeepCopy() is created) set the
condition.ObservedGeneration to cp.Generation (same pattern used in
HTTPRoute/UDPRoute/TCPRoute/GRPCRoute mutators) before applying or replacing the
condition so status updates are allowed to proceed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c51fdc1c-e9c3-43bd-82bc-e50842f7651a

📥 Commits

Reviewing files that changed from the base of the PR and between 9c61ebe and b8ec12f.

📒 Files selected for processing (1)
  • internal/provider/api7ee/status.go

@AlinsRan AlinsRan merged commit 74aea55 into master May 26, 2026
21 of 22 checks passed
@AlinsRan AlinsRan deleted the fix/update-observed-generation-gateway-api-route-status-v2 branch May 26, 2026 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants